CC          = @CC@
AR          = @AR@
RANLIB      = @RANLIB@
LIBNAME     = @LIBNAME@
srcdir      = @srcdir@
CC_SHL      = @CC_SHL@
SHLIBNAME   = @SHLIBNAME@

CPPFLAGS        = @CPPFLAGS@
# I don't like this hard-coded path to the PANFS headers but I guess that's
# where they always are?
INCLUDES    = -I@MPI_INCLUDE_DIR@ -I${srcdir}/../include -I../include -I../../include -I${srcdir}/../../../../include -I../../../../include -I/opt/panfs/include
CFLAGS      = @CFLAGS@ 

top_builddir  = @master_topbuild_dir@
LIBTOOL       = @LIBTOOL@
C_COMPILE       = $(CC) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)
C_COMPILE_SHL   = $(CC_SHL) $(DEFS) $(INCLUDES) $(CFLAGS) $(CPPFLAGS)

@VPATH@

AD_PANFS_OBJECTS = ad_panfs.o ad_panfs_open.o ad_panfs_hints.o ad_panfs_read.o ad_panfs_resize.o ad_panfs_write.o


default: $(LIBNAME)
	@if [ "@ENABLE_SHLIB@" != "none" ] ; then \
		$(MAKE) $(SHLIBNAME).la ;\
	fi

.SUFFIXES: $(SUFFIXES) .p .lo

.c.o:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	  echo "  CC              $<" ; \
	else \
	  echo $(C_COMPILE) -c $< ; \
	fi
	@$(C_COMPILE) -c $<

.c.lo:
	@if [ "x$(VERBOSE)" != "x1" ] ; then \
	  echo "  CC              $<" ; \
	else \
	  echo $(C_COMPILE_SHL) -c $< -o _s$*.o ; \
	  echo mv -f _s$*.o $*.lo ; \
	fi
	@$(C_COMPILE_SHL) -c $< -o _s$*.o
	@mv -f _s$*.o $*.lo


$(LIBNAME): $(AD_PANFS_OBJECTS)
	$(AR) $(LIBNAME) $(AD_PANFS_OBJECTS)
	$(RANLIB) $(LIBNAME) 

AD_PANFS_LOOBJECTS=$(AD_PANFS_OBJECTS:.o=.lo)
$(SHLIBNAME).la: $(AD_PANFS_LOOBJECTS)
	$(AR) $(SHLIBNAME).la $(AD_PANFS_LOOBJECTS)

coverage:
	-@for file in  ${AD_PANFS_OBJECTS:.o=.c} ; do \
		gcov -b -f $$file ; done

clean:
	@rm -f *.o *.lo *.gcno *.gcda *.bb *.bbg
	@rm -f ${srcdir}/*.gcno ${srcdir}/*.gcda 
	@rm -f ${srcdir}/*.bb ${srcdir}/*.bbg
